// JavaScript Document

// Cambiar estilo display de un elemento para mostrarlo/esconderlo
function changeView(id) {
    var obj = document.getElementById(id);
    if (obj!=null) {
        var msgWinStatus = obj.style.display;
        if (msgWinStatus == '') 
            msgWinStatus = 'none';
        else
            msgWinStatus = '';
    
        obj.style.display = msgWinStatus;
    }
}


//Description: Search criteria is passed in, along with a list box to search for a Item. As search criteria is passed in, this function scans the list box for a matching option, it then selects the first match. If search criteria is empty then the function unselects all options. This works like the any help menu
//Precondition: field be a valued select box
//Postcondition: First match of the search criteria in 'field' is selected
//Use: onkeyup='Find_Term(this, this.form.<select id>);'
function Find_Term(search,field,no_select)
{
	var valor = search.value;
	var pattern

	if (valor == "") //No se selecciono ningun valor
		valor = no_select;

	//Use "i" to make search not case-sensitive
	pattern = new RegExp("^" + valor, "i");

	for(var x=0; x < field.options.length; x++)
	{

		if (pattern.test(field.options[x].text) == true)
		{

			field.options[x].selected = true
			break;

		}
	}
}


function clearInput(input) {
	obj = document.getElementById(input);
	obj.value = '';
	obj.focus();
}


function hideForm(f) {
	var obj = document.getElementById(f);
	obj.style.display = 'none';
}